﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;

using Dynamic.Core.AD;
using Dynamic.Core.Utility;

namespace Dynamic.Testing.AD
{
    public class ADTest
    {
        public static void Go()
        {
            ADUtility.Exists("LDAP://cn=users,dc=acontest,dc=com");


            OU ou = new OU();
            ou.Name = "test";
            ou.Add("LDAP://ou=acon,dc=acontest,dc=com");


            ADUser user = new ADUser();
            user.UserName = "david.cao";
            user.FirstName = "david";
            user.LastName = "cao";
            user.Mail = "cao562@yahoo.com.cn";
            user.Telephone = "13738078819";

            user.Add("", "Abcd123");

            ADUtility.FriendlyDomainToLdapDomain("acon.acontest");
            ADUtility.EnumerateDomains();

            ADUser dd = ADUtility.GetUserByPrincipalName("david6.cao@acontest.com", null, null);
            if (dd != null)
                dd.Remove();


            ADUser d2 = ADUtility.GetUserBySAMAccountName("david6.cao", null, null);
            if (d2 != null)
                d2.Remove();
            //user.Remove();
            //DirectoryEntry de = ADUtility.GetAppSetDomain();

            List<string> enumerateDomains = ADUtility.EnumerateDomains();
            List<string> enumerateGlobalCatalogs = ADUtility.EnumerateGlobalCatalogs();
            List<string> enumerateDomainControllers = ADUtility.EnumerateDomainControllers();
        }
    }
}
